import React, { Component } from 'react';
import { connect } from 'dva';
import { Card } from 'antd';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import { Link } from 'dva/router';
import { SSL_OP_PKCS1_CHECK_2 } from 'constants';
@connect((state, ownProps) => {
  const {
    articles: { entities },
  } = state;
  const {
    match: {
      params: { id },
    },
  } = ownProps;
  return {
    ...entities[id],
  };
})
class Show extends Component {
  componentDidMount() {
    const {
      match: {
        params: { id },
      },
    } = this.props;
    const { id: articleId } = this.props;
    if (!articleId) {
      this.props.dispatch({
        type: 'articles/getArticleById',
        articleId: id,
      });
    }
  }

  render() {
    const { title, content } = this.props;
    return (
      <PageHeaderLayout title="标题">
        <Card bordered={false}>
          <p>标题</p>
          <p>{title}</p>
          <p>内容</p>
          <p>{content}</p>
          <Link to="/articles/show/5678">到文章2</Link>
        </Card>
      </PageHeaderLayout>
    );
  }
}

export default Show;
